package com.cn.kehong.controller;


import com.cn.kehong.api.IProductDianciFenjService;
import com.cn.kehong.domain.ProductDianciFenj;
import com.cn.kehong.utils.CommonUtil;
import com.cn.kehong.utils.JsonResponse;
import com.cn.kehong.utils.QueryForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/fenj")
public class ProductDianciFenjController {

    @Autowired
    private IProductDianciFenjService productDianciFenjService;

    @RequestMapping("/getProductDianciFenjList/{frontToken}")
    @ResponseBody
    public JsonResponse<List<ProductDianciFenj>> getProductDianciFenjList(QueryForm queryForm, @PathVariable(value = "frontToken", required = true) String frontToken) throws Exception {
        JsonResponse<List<ProductDianciFenj>> response = new JsonResponse<List<ProductDianciFenj>>();
        List<ProductDianciFenj> lists = productDianciFenjService.getProductDianciFenjList(queryForm);
        response.setResult(lists);
        response.setSuccess(true);
        return response;
    }

    @RequestMapping("/getProductDianciFenjListByStatus/{frontToken}")
    @ResponseBody
    public JsonResponse<List<ProductDianciFenj>> getProductDianciFenjListByStatus(QueryForm queryForm, @PathVariable(value = "frontToken", required = true) String frontToken) throws Exception {
        JsonResponse<List<ProductDianciFenj>> response = new JsonResponse<List<ProductDianciFenj>>();
        List<ProductDianciFenj> lists = productDianciFenjService.getProductDianciFenjListByStatus(queryForm);
        response.setResult(lists);
        response.setSuccess(true);
        return response;
    }


    @RequestMapping("/getProductDianciFenjListWithPackage/{frontToken}")
    @ResponseBody
    public JsonResponse<List<ProductDianciFenj>> getProductDianciFenjListWithPackage(QueryForm queryForm, @PathVariable(value = "frontToken", required = true) String frontToken) throws Exception {
        JsonResponse<List<ProductDianciFenj>> response = new JsonResponse<List<ProductDianciFenj>>();
        List<ProductDianciFenj> lists = productDianciFenjService.getProductDianciFenjListWithPackage(queryForm);
        response.setResult(lists);
        response.setSuccess(true);
        return response;
    }

    @RequestMapping("/updateEndProductDianciFenj/{frontToken}")
    @ResponseBody
    public JsonResponse<String> updateEndProductDianciFenj(ProductDianciFenj productDianciFenj, @PathVariable(value =  "frontToken",required = true) String frontToken) throws Exception{
        JsonResponse<String> response = new JsonResponse<>();
        String result = productDianciFenjService.updateEndProductDianciFenj(productDianciFenj);
        return CommonUtil.getResponseData(response,result);
    }

}
